<?php
/**
 *
 *  The upload procedure looks like this:
 *  ###- set upload path
 *  - verify the status (no error, is uploaded file)
 *  - select a handler for uploaded file (eg. an image, a parsable text etc)
 *  - process upload using the handler
 *
 *  The upload handler must be instanceof UploadInterface:
 *
 */
namespace Yz\modules\Uploads;

use FileError;

class Action_UploadImage
    extends Action_Upload
{
    /**
     *  @var Yz_Image_Default
     */
    protected $image;


    /**************************
     *      Public methods    *
     **************************/


    /**
     *  @return array
     */
    public function __construct(\Yz_Model_Interface $model)
    {
        debug();
        parent::__construct($model);
        $this->__dict__['image'] = null;
        $this->__dict__['width'] = null;
        $this->__dict__['height'] = null;
        return $this;
    }


    /*****************************
     *      Protected methods    *
     *****************************/


    /**
     *
     *  @todo
     */
    protected function verifyUpload()
    {
        debug();
        $file = new \Yz_File($this->tempName);
        $this->image = \Yz_Image_Default::fromFile($file);
        $this->__dict__['image'] = $this->image;
        $this->__dict__['width'] = $this->image->getWidth();
        $this->__dict__['height'] = $this->image->getHeight();
        return $this;
    }

}
